package com.example.mgsnew.utils;

import com.fasterxml.jackson.databind.ObjectMapper;


//将json字符转化为具体的实体类
public class JsonUtil {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    public static String toJson(Object object) throws Exception {
        return objectMapper.writeValueAsString(object);
    }

    public static <T> T fromJson(String json, Class<T> clazz) throws Exception {
        return objectMapper.readValue(json, clazz);
    }

//转化为Task实体类
//    Task task = JsonUtil.fromJson(message, Task.class);


    ////将Task实体类转化为json对象
//    Task task = new Task();
//task.setTaskId("1");
//task.setTaskType("PROCESS_DATA");
//task.setPayload("Some data");
//
//    String message = JsonUtil.toJson(task);
//channel.basicPublish("", queuesConfig.getTopicQueueTask(), null, message.getBytes("UTF-8"));
}
